/**
 * Mock 数据服务
 * 用于前端开发时模拟后端 API 响应
 * 
 * ============================================
 * 【重要】Mock数据使用状况说明（更新时间：2025-10-31）
 * ============================================
 * 
 * ✅ 已对接真实后端API（不再使用Mock）：
 * - 用户认证：mockLogin, mockRegister → 已改用 /api/auth/login, /api/auth/register
 * - 用户信息：mockGetUserInfo, mockUpdateUser → 已改用 /api/user（GET/PUT）
 * - 帖子管理：mockGetPosts, mockGetPost, mockPublishPost, mockDeletePost → 已改用 /api/posts, /api/post
 * - 评论功能：mockGetComments, mockPublishComment → 已改用 /api/post/comments, /api/post/comment
 * - 板块列表：mockGetPlates → 已改用 /api/plates
 * 
 * ⚠️ 仍在使用Mock（后端未实现）：
 * - 子分类：mockGetSubCategories - 后端未实现二级分类功能
 * - 点赞收藏：mockLikePost, mockUnlikePost, mockCollectPost, mockUncollectPost
 * - 活动管理：mockGetActivities, mockGetActivity
 * - 公告系统：mockGetNotices
 * - 聊天室：mockGetChatrooms, mockGetChatroomDetail, mockCreateChatroom, mockSendMessage等
 * - 消息通知：mockGetMessages, mockMarkMessageAsRead, mockGetUnreadCount等
 * 
 * 📝 数据适配说明：
 * - 前后端字段差异通过 utils/dataAdapter.js 进行转换
 * - 主要差异：nickName↔nickname, Introduction↔introduction, image字符串↔数组
 * - 详细问题记录见：前后端接口对接问题记录.md
 * 
 * ============================================
 */

// ====================================================================
// 模拟用户数据
// ====================================================================
const mockUsers = [{
		userId: 1,
		serialNumber: '2025001',
		uname: 'admin',
		nickname: '校园管理员',
		password: '123456',
		phoneNumber: '13800138000',
		avatar: 'https://picsum.photos/200/200?random=1',
		gender: 1,
		introduction: '负责校园平台日常管理，处理违规内容',
		birthday: '1990-01-15',
		college: '行政办公室',
		major: '行政管理',
		role: 1,
		status: 0
	},
	{
		userId: 2,
		serialNumber: '2023001',
		uname: 'student1',
		nickname: '小码农',
		password: '123456',
		phoneNumber: '13900139001',
		avatar: 'https://picsum.photos/200/200?random=2',
		gender: 1,
		introduction: '计算机学院大三学生，喜欢编程和篮球',
		birthday: '2005-03-20',
		college: '计算机学院',
		major: '软件工程',
		role: 0,
		status: 0
	},
	{
		userId: 3,
		serialNumber: '2023002',
		uname: 'student2',
		nickname: '小书虫',
		password: '123456',
		phoneNumber: '13900139002',
		avatar: 'https://picsum.photos/200/200?random=3',
		gender: 2,
		introduction: '文学院大二学生，爱读书、爱分享',
		birthday: '2006-09-10',
		college: '文学院',
		major: '汉语言文学',
		role: 0,
		status: 0
	}
];

// ====================================================================
// 模拟板块数据（优化版 v3.0 - 4大板块）
// ====================================================================

// 一级板块（4个核心板块）
const mockPlates = [
	{
		plateId: 1,
		parentId: 0,
		plateName: '讨论',
		plateDesc: '自由讨论，分享观点，畅所欲言',
		icon: 'chat',
		color: '#1890ff',
		template: 'post',
		sort: 1,
		status: 0
	},
	{
		plateId: 2,
		parentId: 0,
		plateName: '分享',
		plateDesc: '分享学习资料、好物推荐、美图照片',
		icon: 'share',
		color: '#52c41a',
		template: 'post',
		sort: 2,
		status: 0
	},
	{
		plateId: 3,
		parentId: 0,
		plateName: '交易',
		plateDesc: '二手物品交易，闲置物品买卖',
		icon: 'shopping-cart',
		color: '#fa8c16',
		template: 'trade',
		sort: 3,
		status: 0
	},
	{
		plateId: 4,
		parentId: 0,
		plateName: '求助',
		plateDesc: '寻求帮助，互帮互助，解决问题',
		icon: 'question-circle',
		color: '#722ed1',
		template: 'help',
		sort: 4,
		status: 0
	}
];

// 二级分类
const mockSubCategories = {
	1: [ // 讨论
		{ id: 11, name: '学习', desc: '课程问题、考研交流、学习方法分享' },
		{ id: 12, name: '生活', desc: '校园趣事、生活感悟、日常吐槽' },
		{ id: 13, name: '情感', desc: '情感倾诉、心情分享' },
		{ id: 14, name: '校园', desc: '宿舍话题、食堂讨论、社团活动' }
	],
	2: [ // 分享
		{ id: 21, name: '学习资料', desc: '课程资料、考研资料、电子书籍' },
		{ id: 22, name: '好物', desc: '数码产品、生活好物、美食推荐' },
		{ id: 23, name: '美图', desc: '校园风景、摄影作品、旅行照片' },
		{ id: 24, name: '经验', desc: '学习经验、生活技巧分享' }
	],
	3: [ // 交易
		{ id: 31, name: '电子产品', desc: '手机平板、电脑配件、耳机音响' },
		{ id: 32, name: '生活用品', desc: '服装鞋帽、日用百货、运动器材' },
		{ id: 33, name: '图书', desc: '教材教辅、课外读物、考研资料' },
		{ id: 34, name: '其他', desc: '其他闲置物品' }
	],
	4: [ // 求助
		{ id: 41, name: '学习', desc: '课程辅导、作业答疑、项目合作' },
		{ id: 42, name: '生活', desc: '拼车拼团、帮忙代取、紧急求助' },
		{ id: 43, name: '技术', desc: '编程问题、软件使用、网络故障' },
		{ id: 44, name: '其他', desc: '其他求助需求' }
	]
};

// ====================================================================
// 模拟帖子数据（优化版 v3.0 - 4大板块）
// ====================================================================
const mockPosts = [
	// ===== 板块1：讨论 =====
	{
		postId: 1,
		title: '大家觉得高数期末会很难吗？',
		content: '马上要期末考试了，感觉高数好难啊，有没有学长学姐分享一下经验？复习重点是什么？',
		image: [],
		status: 0,
		viewCount: 189,
		likeCount: 23,
		collectCount: 8,
		commentCount: 15,
		isTop: 0,
		isEssence: 0,
		plateId: 1,
		subCategory: '学习',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		createTime: Date.now() - 86400000 * 5,
		updateTime: Date.now() - 86400000 * 3
	},
	{
		postId: 2,
		title: '今天食堂的新菜品你们吃了吗？',
		content: '三楼新开的麻辣烫窗口真的绝了！料足价格实惠，强烈推荐！',
		image: ['https://picsum.photos/600/400?random=20'],
		status: 0,
		viewCount: 256,
		likeCount: 67,
		collectCount: 23,
		commentCount: 28,
		isTop: 0,
		isEssence: 0,
		plateId: 1,
		subCategory: '校园',
		userId: 3,
		nickname: '小书虫',
		avatar: 'https://picsum.photos/200/200?random=3',
		createTime: Date.now() - 86400000 * 3,
		updateTime: Date.now() - 86400000 * 2
	},
	{
		postId: 3,
		title: '吐槽一下宿舍熄灯时间',
		content: '为什么要11点就熄灯啊，根本不够用！大家都是怎么解决的？',
		image: [],
		status: 0,
		viewCount: 334,
		likeCount: 89,
		collectCount: 12,
		commentCount: 45,
		isTop: 0,
		isEssence: 0,
		plateId: 1,
		subCategory: '生活',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		createTime: Date.now() - 86400000 * 8,
		updateTime: Date.now() - 86400000 * 6
	},

	// ===== 板块2：分享 =====
	{
		postId: 4,
		title: '计算机网络期末复习资料（PDF）',
		content: '整理了计算机网络的期末复习资料，包含重点知识点和历年真题，需要的同学可以下载。',
		image: ['https://picsum.photos/600/400?random=21'],
		status: 0,
		viewCount: 567,
		likeCount: 145,
		collectCount: 234,
		commentCount: 56,
		isTop: 0,
		isEssence: 1,
		plateId: 2,
		subCategory: '学习资料',
		userId: 3,
		nickname: '小书虫',
		avatar: 'https://picsum.photos/200/200?random=3',
		attachments: [{ name: '计算机网络复习.pdf', size: '2.3MB', url: '' }],
		createTime: Date.now() - 86400000 * 12,
		updateTime: Date.now() - 86400000 * 10
	},
	{
		postId: 5,
		title: '安利一款超好用的笔记本电脑',
		content: '用了半年的联想小新Pro16，真的很不错！性价比超高，推荐给需要的同学。',
		image: ['https://picsum.photos/600/400?random=22', 'https://picsum.photos/600/400?random=23'],
		status: 0,
		viewCount: 389,
		likeCount: 98,
		collectCount: 67,
		commentCount: 34,
		isTop: 0,
		isEssence: 0,
		plateId: 2,
		subCategory: '好物',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		createTime: Date.now() - 86400000 * 10,
		updateTime: Date.now() - 86400000 * 8
	},
	{
		postId: 6,
		title: '校园秋景真的太美了',
		content: '今天傍晚拍的校园秋景，分享给大家～',
		image: ['https://picsum.photos/600/400?random=24', 'https://picsum.photos/600/400?random=25', 'https://picsum.photos/600/400?random=26'],
		status: 0,
		viewCount: 678,
		likeCount: 289,
		collectCount: 178,
		commentCount: 67,
		isTop: 0,
		isEssence: 1,
		plateId: 2,
		subCategory: '美图',
		userId: 3,
		nickname: '小书虫',
		avatar: 'https://picsum.photos/200/200?random=3',
		createTime: Date.now() - 86400000 * 6,
		updateTime: Date.now() - 86400000 * 4
	},

	// ===== 板块3：交易 =====
	{
		postId: 7,
		title: 'iPhone 14 Pro 256G 深空黑',
		content: '去年双11买的iPhone 14 Pro，256G深空黑，99新，电池健康度98%。配件齐全，有发票。价格5800，可小刀。',
		image: ['https://picsum.photos/600/400?random=27', 'https://picsum.photos/600/400?random=28'],
		status: 0,
		viewCount: 456,
		likeCount: 67,
		collectCount: 45,
		commentCount: 23,
		isTop: 0,
		isEssence: 0,
		plateId: 3,
		subCategory: '电子产品',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		tradePrice: 5800.00,
		tradeStatus: 'available',
		tradeCondition: '99新',
		contactInfo: '微信：abc123',
		createTime: Date.now() - 86400000 * 15,
		updateTime: Date.now() - 86400000 * 12
	},
	{
		postId: 8,
		title: '护眼台灯 9成新 急转',
		content: '宿舍用的护眼台灯，买了一学期，9成新，搬宿舍带不走了，原价199，现50转。',
		image: ['https://picsum.photos/600/400?random=29'],
		status: 0,
		viewCount: 234,
		likeCount: 34,
		collectCount: 23,
		commentCount: 12,
		isTop: 0,
		isEssence: 0,
		plateId: 3,
		subCategory: '生活用品',
		userId: 3,
		nickname: '小书虫',
		avatar: 'https://picsum.photos/200/200?random=3',
		tradePrice: 50.00,
		tradeStatus: 'available',
		tradeCondition: '9成新',
		contactInfo: 'QQ：123456',
		createTime: Date.now() - 86400000 * 18,
		updateTime: Date.now() - 86400000 * 15
	},
	{
		postId: 9,
		title: '数据结构教材 清华版',
		content: '用完的数据结构教材，清华大学出版社，无笔记无划线，8成新，30元包邮。',
		image: ['https://picsum.photos/600/400?random=30'],
		status: 0,
		viewCount: 178,
		likeCount: 23,
		collectCount: 15,
		commentCount: 8,
		isTop: 0,
		isEssence: 0,
		plateId: 3,
		subCategory: '图书',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		tradePrice: 30.00,
		tradeStatus: 'sold',
		tradeCondition: '8成新',
		contactInfo: '电话：139****1234',
		createTime: Date.now() - 86400000 * 20,
		updateTime: Date.now() - 86400000 * 18
	},

	// ===== 板块4：求助 =====
	{
		postId: 10,
		title: 'C语言作业求助',
		content: '有没有大佬帮忙看看这道C语言题怎么做？在线等，挺急的！',
		image: ['https://picsum.photos/600/400?random=31'],
		status: 0,
		viewCount: 345,
		likeCount: 56,
		collectCount: 12,
		commentCount: 28,
		isTop: 0,
		isEssence: 0,
		plateId: 4,
		subCategory: '学习',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		helpStatus: 'resolved',
		helpUrgency: '今天内',
		helpReward: '请吃饭',
		contactInfo: '微信：student001',
		createTime: Date.now() - 86400000 * 7,
		updateTime: Date.now() - 86400000 * 6
	},
	{
		postId: 11,
		title: '明早7点代取快递',
		content: '明天有课起不来，有没有同学能帮忙代取一下快递？菜鸟驿站。',
		image: [],
		status: 0,
		viewCount: 267,
		likeCount: 34,
		collectCount: 8,
		commentCount: 15,
		isTop: 0,
		isEssence: 0,
		plateId: 4,
		subCategory: '生活',
		userId: 3,
		nickname: '小书虫',
		avatar: 'https://picsum.photos/200/200?random=3',
		helpStatus: 'in_progress',
		helpUrgency: '紧急',
		helpReward: '10元',
		contactInfo: 'QQ：987654321',
		createTime: Date.now() - 86400000 * 2,
		updateTime: Date.now() - 86400000 * 1
	},
	{
		postId: 12,
		title: '电脑蓝屏求修',
		content: '电脑突然蓝屏了，不知道怎么回事，有没有懂电脑的同学帮忙看看？',
		image: [],
		status: 0,
		viewCount: 189,
		likeCount: 23,
		collectCount: 5,
		commentCount: 12,
		isTop: 0,
		isEssence: 0,
		plateId: 4,
		subCategory: '技术',
		userId: 2,
		nickname: '小码农',
		avatar: 'https://picsum.photos/200/200?random=2',
		helpStatus: 'pending',
		helpUrgency: '不急',
		helpReward: '可付费',
		contactInfo: '电话：138****5678',
		createTime: Date.now() - 86400000 * 4,
		updateTime: Date.now() - 86400000 * 3
	}
];

// ====================================================================
// 模拟评论数据
// ====================================================================
const mockComments = [{
		commentId: 1,
		postId: 1,
		userId: 3,
		sender: '小书虫',
		senderAvatar: 'https://picsum.photos/200/200?random=3',
		replyUserId: null,
		receiver: null,
		parentId: 0,
		content: '请问报到需要带疫苗接种证明吗？',
		status: 0,
		createTime: Date.now() - 86400000 * 39
	},
	{
		commentId: 2,
		postId: 1,
		userId: 1,
		sender: '校园管理员',
		senderAvatar: 'https://picsum.photos/200/200?random=1',
		replyUserId: 3,
		receiver: '小书虫',
		parentId: 1,
		content: '不需要带疫苗证明，只需身份证和校园卡即可。',
		status: 0,
		createTime: Date.now() - 86400000 * 39 + 300000
	}
];

// ====================================================================
// 模拟活动数据
// ====================================================================
const mockActivities = [{
		activityId: 1,
		title: '2025年秋季运动会',
		content: '一年一度的秋季运动会即将开始！设有100米、200米、跳远、铅球等多个项目。欢迎同学们报名参加，展现青春活力！',
		image: 'https://picsum.photos/600/400?random=300',
		location: '校田径场',
		startTime: '2025-10-20 08:00:00',
		endTime: '2025-10-22 18:00:00',
		maxParticipants: 0,
		currentParticipants: 89,
		status: 1,
		organizerId: 1,
		organizerName: '校园管理员',
		createTime: Date.now() - 86400000 * 45
	},
	{
		activityId: 2,
		title: '校园歌手大赛初赛',
		content: '展示你的歌喉，成为校园之星！本次比赛分为初赛、复赛、决赛三个阶段。',
		image: 'https://picsum.photos/600/400?random=301',
		location: '大学生活动中心',
		startTime: '2025-11-15 19:00:00',
		endTime: '2025-11-15 22:00:00',
		maxParticipants: 200,
		currentParticipants: 78,
		status: 0,
		organizerId: 1,
		organizerName: '校园管理员',
		createTime: Date.now() - 86400000 * 42
	}
];

// ====================================================================
// 模拟公告数据
// ====================================================================
const mockNotices = [{
		noticeId: 1,
		title: '校园平台小程序正式上线！',
		content: '欢迎大家使用校园平台小程序！在这里你可以发布帖子、参与讨论、查找失物、交易闲置物品等。',
		type: '通知',
		status: 0,
		createTime: Date.now() - 86400000 * 60
	},
	{
		noticeId: 2,
		title: '平台功能优化公告',
		content: '本次更新优化了帖子加载速度，修复了图片上传失败的问题，新增了评论点赞功能。',
		type: '优化',
		status: 0,
		createTime: Date.now() - 86400000 * 30
	},
	{
		noticeId: 3,
		title: '禁止发布违规内容的重要提醒',
		content: '请各位同学遵守平台规则，严禁发布违法违规、虚假信息、广告等内容，违者将被封号处理。',
		type: '紧急',
		status: 0,
		createTime: Date.now() - 86400000 * 20
	}
];

// ====================================================================
// 模拟聊天室数据
// ====================================================================
const mockChatrooms = [
	{
		roomId: 1,
		roomName: '计算机学院交流群',
		roomDesc: '计算机学院的同学们交流学习、分享资源的地方',
		avatar: 'https://picsum.photos/200/200?random=100',
		creatorId: 2,
		creatorName: '小码农',
		onlineCount: 23,
		memberCount: 156,
		lastMessage: '有没有人知道数据结构作业怎么做？',
		lastMessageTime: Date.now() - 300000, // 5分钟前
		unreadCount: 3,
		status: 0,
		createTime: Date.now() - 86400000 * 30
	},
	{
		roomId: 2,
		roomName: '摄影爱好者',
		roomDesc: '分享摄影作品，交流摄影技巧',
		avatar: 'https://picsum.photos/200/200?random=101',
		creatorId: 3,
		creatorName: '小书虫',
		onlineCount: 8,
		memberCount: 67,
		lastMessage: '今天拍的校园秋景，大家看看～',
		lastMessageTime: Date.now() - 600000, // 10分钟前
		unreadCount: 0,
		status: 0,
		createTime: Date.now() - 86400000 * 25
	},
	{
		roomId: 3,
		roomName: '考研交流群',
		roomDesc: '考研的同学们互相鼓励，分享复习经验',
		avatar: 'https://picsum.photos/200/200?random=102',
		creatorId: 2,
		creatorName: '小码农',
		onlineCount: 45,
		memberCount: 234,
		lastMessage: '加油！我们一定可以的！',
		lastMessageTime: Date.now() - 1800000, // 30分钟前
		unreadCount: 15,
		status: 0,
		createTime: Date.now() - 86400000 * 60
	},
	{
		roomId: 4,
		roomName: '二手交易',
		roomDesc: '买卖闲置物品，节约又环保',
		avatar: 'https://picsum.photos/200/200?random=103',
		creatorId: 1,
		creatorName: '校园管理员',
		onlineCount: 12,
		memberCount: 89,
		lastMessage: '全新台灯低价转让',
		lastMessageTime: Date.now() - 3600000, // 1小时前
		unreadCount: 0,
		status: 0,
		createTime: Date.now() - 86400000 * 45
	},
	{
		roomId: 5,
		roomName: '篮球爱好者',
		roomDesc: '一起打篮球，交流球技',
		avatar: 'https://picsum.photos/200/200?random=104',
		creatorId: 2,
		creatorName: '小码农',
		onlineCount: 6,
		memberCount: 43,
		lastMessage: '明天下午3点操场见！',
		lastMessageTime: Date.now() - 7200000, // 2小时前
		unreadCount: 0,
		status: 0,
		createTime: Date.now() - 86400000 * 20
	},
	{
		roomId: 6,
		roomName: '英语学习角',
		roomDesc: '提高英语水平，练习口语',
		avatar: 'https://picsum.photos/200/200?random=105',
		creatorId: 3,
		creatorName: '小书虫',
		onlineCount: 15,
		memberCount: 112,
		lastMessage: 'Can anyone recommend a good English learning app?',
		lastMessageTime: Date.now() - 10800000, // 3小时前
		unreadCount: 0,
		status: 0,
		createTime: Date.now() - 86400000 * 50
	},
	{
		roomId: 7,
		roomName: '美食分享',
		roomDesc: '分享美食，交流厨艺',
		avatar: 'https://picsum.photos/200/200?random=106',
		creatorId: 2,
		creatorName: '小码农',
		onlineCount: 9,
		memberCount: 78,
		lastMessage: '今天做的红烧肉，超级好吃～',
		lastMessageTime: Date.now() - 14400000, // 4小时前
		unreadCount: 0,
		status: 0,
		createTime: Date.now() - 86400000 * 35
	},
	{
		roomId: 8,
		roomName: '游戏开黑',
		roomDesc: '一起玩游戏，寻找队友',
		avatar: 'https://picsum.photos/200/200?random=107',
		creatorId: 2,
		creatorName: '小码农',
		onlineCount: 18,
		memberCount: 156,
		lastMessage: '晚上8点开黑，还差2个人',
		lastMessageTime: Date.now() - 18000000, // 5小时前
		unreadCount: 0,
		status: 0,
		createTime: Date.now() - 86400000 * 40
	}
];

// ====================================================================
// 模拟用户-聊天室关系数据（用户加入的聊天室）
// ====================================================================
const mockUserChatroomRelations = [
	{ userId: 2, roomId: 1, status: 'joined', joinTime: Date.now() - 86400000 * 30 },
	{ userId: 2, roomId: 2, status: 'joined', joinTime: Date.now() - 86400000 * 25 },
	{ userId: 2, roomId: 3, status: 'joined', joinTime: Date.now() - 86400000 * 60 },
	{ userId: 2, roomId: 5, status: 'joined', joinTime: Date.now() - 86400000 * 20 },
	{ userId: 2, roomId: 8, status: 'joined', joinTime: Date.now() - 86400000 * 40 },
	{ userId: 3, roomId: 1, status: 'joined', joinTime: Date.now() - 86400000 * 28 },
	{ userId: 3, roomId: 2, status: 'joined', joinTime: Date.now() - 86400000 * 24 },
	{ userId: 3, roomId: 6, status: 'joined', joinTime: Date.now() - 86400000 * 50 }
];

// ====================================================================
// 模拟消息通知数据
// ====================================================================
const mockMessages = [
	// 回复类消息
	{
		messageId: 1,
		type: 'reply',
		title: '小书虫回复了你的帖子',
		content: '这个问题我也遇到过，可以试试重启电脑解决',
		relatedType: 'post', // 关联类型：post(帖子)、comment(评论)
		relatedId: 12, // 关联的帖子/评论ID
		relatedTitle: '电脑蓝屏求修',
		senderId: 3,
		senderName: '小书虫',
		senderAvatar: 'https://picsum.photos/200/200?random=3',
		isRead: 0,
		createTime: Date.now() - 3600000 // 1小时前
	},
	{
		messageId: 2,
		type: 'reply',
		title: '你的帖子收到新评论',
		content: '请问这个还在吗？价格能不能再优惠一点？',
		relatedType: 'post',
		relatedId: 7,
		relatedTitle: 'iPhone 14 Pro 256G 深空黑',
		senderId: 1,
		senderName: '校园管理员',
		senderAvatar: 'https://picsum.photos/200/200?random=1',
		isRead: 0,
		createTime: Date.now() - 7200000 // 2小时前
	},
	{
		messageId: 3,
		type: 'reply',
		title: '小码农回复了你',
		content: '高数重点看课本例题和课后习题，历年真题也很重要',
		relatedType: 'post',
		relatedId: 1,
		relatedTitle: '大家觉得高数期末会很难吗？',
		senderId: 2,
		senderName: '小码农',
		senderAvatar: 'https://picsum.photos/200/200?random=2',
		isRead: 1,
		createTime: Date.now() - 86400000 * 1 // 1天前
	},
	
	// 系统消息
	{
		messageId: 4,
		type: 'system',
		title: '你的帖子已被管理员加精',
		content: '恭喜！你发布的帖子《校园秋景真的太美了》因内容优质已被管理员设为精华帖',
		relatedType: 'post',
		relatedId: 6,
		relatedTitle: '校园秋景真的太美了',
		isRead: 0,
		createTime: Date.now() - 10800000 // 3小时前
	},
	{
		messageId: 5,
		type: 'system',
		title: '你的帖子已被置顶',
		content: '你的帖子《计算机网络期末复习资料（PDF）》已被管理员置顶',
		relatedType: 'post',
		relatedId: 4,
		relatedTitle: '计算机网络期末复习资料（PDF）',
		isRead: 1,
		createTime: Date.now() - 86400000 * 2 // 2天前
	},
	{
		messageId: 6,
		type: 'system',
		title: '账号安全提醒',
		content: '检测到你的账号在新设备登录，如非本人操作请及时修改密码',
		isRead: 1,
		createTime: Date.now() - 86400000 * 3 // 3天前
	},
	
	// 官方消息
	{
		messageId: 7,
		type: 'official',
		title: '平台功能升级通知',
		content: '平台将于今晚23:00-24:00进行系统维护升级，届时将暂时无法访问，给您带来不便敬请谅解',
		isRead: 0,
		createTime: Date.now() - 14400000 // 4小时前
	},
	{
		messageId: 8,
		type: 'official',
		title: '新功能上线公告',
		content: '消息通知功能正式上线！现在你可以及时接收到回复、系统通知、官方消息等，不错过任何重要信息',
		isRead: 0,
		createTime: Date.now() - 18000000 // 5小时前
	},
	{
		messageId: 9,
		type: 'official',
		title: '社区规范提醒',
		content: '请各位用户遵守社区规范，文明发帖，禁止发布违法违规、虚假信息等内容',
		isRead: 1,
		createTime: Date.now() - 86400000 * 5 // 5天前
	},
	
	// 活动消息
	{
		messageId: 10,
		type: 'activity',
		title: '你报名的活动即将开始',
		content: '你报名的活动《2025年秋季运动会》将于明天上午8:00开始，请准时参加',
		relatedType: 'activity',
		relatedId: 1,
		relatedTitle: '2025年秋季运动会',
		isRead: 0,
		createTime: Date.now() - 21600000 // 6小时前
	},
	{
		messageId: 11,
		type: 'activity',
		title: '新活动邀请',
		content: '《校园歌手大赛初赛》正在报名中，快来展示你的才华吧！',
		relatedType: 'activity',
		relatedId: 2,
		relatedTitle: '校园歌手大赛初赛',
		isRead: 1,
		createTime: Date.now() - 86400000 * 4 // 4天前
	},
	
	// 其它消息
	{
		messageId: 12,
		type: 'other',
		title: '小书虫关注了你',
		content: '小书虫开始关注你了，快去看看TA的主页吧',
		relatedType: 'user',
		relatedId: 3,
		senderId: 3,
		senderName: '小书虫',
		senderAvatar: 'https://picsum.photos/200/200?random=3',
		isRead: 0,
		createTime: Date.now() - 25200000 // 7小时前
	},
	{
		messageId: 13,
		type: 'other',
		title: '你的帖子获得点赞',
		content: '小码农点赞了你的帖子《校园秋景真的太美了》',
		relatedType: 'post',
		relatedId: 6,
		relatedTitle: '校园秋景真的太美了',
		senderId: 2,
		senderName: '小码农',
		senderAvatar: 'https://picsum.photos/200/200?random=2',
		isRead: 1,
		createTime: Date.now() - 86400000 * 1 // 1天前
	},
	{
		messageId: 14,
		type: 'other',
		title: '收藏提醒',
		content: '你收藏的帖子《计算机网络期末复习资料（PDF）》有新的更新',
		relatedType: 'post',
		relatedId: 4,
		relatedTitle: '计算机网络期末复习资料（PDF）',
		isRead: 1,
		createTime: Date.now() - 86400000 * 6 // 6天前
	}
];

// ====================================================================
// 模拟聊天消息数据
// ====================================================================
const mockChatroomMessages = {
	1: [ // 计算机学院交流群的消息
		{
			messageId: 1,
			roomId: 1,
			userId: 3,
			nickname: '小书虫',
			avatar: 'https://picsum.photos/200/200?random=3',
			type: 'text',
			content: '大家好，我是新来的',
			isSelf: false,
			createTime: Date.now() - 3600000 * 2
		},
		{
			messageId: 2,
			roomId: 1,
			userId: 2,
			nickname: '小码农',
			avatar: 'https://picsum.photos/200/200?random=2',
			type: 'text',
			content: '欢迎欢迎！👏',
			isSelf: true,
			createTime: Date.now() - 3600000 * 2 + 60000
		},
		{
			messageId: 3,
			roomId: 1,
			userId: 1,
			nickname: '校园管理员',
			avatar: 'https://picsum.photos/200/200?random=1',
			type: 'text',
			content: '请大家遵守群规，文明交流',
			isSelf: false,
			createTime: Date.now() - 3600000 * 2 + 120000
		},
		{
			messageId: 4,
			roomId: 1,
			userId: 3,
			nickname: '小书虫',
			avatar: 'https://picsum.photos/200/200?random=3',
			type: 'text',
			content: '有没有人知道数据结构作业怎么做？',
			isSelf: false,
			createTime: Date.now() - 300000
		}
	],
	2: [ // 摄影爱好者的消息
		{
			messageId: 5,
			roomId: 2,
			userId: 3,
			nickname: '小书虫',
			avatar: 'https://picsum.photos/200/200?random=3',
			type: 'text',
			content: '今天拍的校园秋景，大家看看～',
			isSelf: false,
			createTime: Date.now() - 600000
		},
		{
			messageId: 6,
			roomId: 2,
			userId: 3,
			nickname: '小书虫',
			avatar: 'https://picsum.photos/200/200?random=3',
			type: 'image',
			content: 'https://picsum.photos/600/400?random=200',
			isSelf: false,
			createTime: Date.now() - 600000 + 5000
		}
	]
};

// ====================================================================
// Mock API 方法
// ====================================================================

/**
 * 模拟延迟
 */
const delay = (ms = 500) => new Promise(resolve => setTimeout(resolve, ms));

/**
 * 模拟统一响应格式
 */
const mockResponse = (data, message = '操作成功') => {
	return {
		code: 200,
		message,
		data
	};
};

/**
 * 模拟错误响应
 */
const mockError = (message = '操作失败', code = 400) => {
	return {
		code,
		message,
		data: null
	};
};

// ====================================================================
// 用户相关 Mock API
// ====================================================================

/**
 * 模拟登录
 */
export const mockLogin = async (uname, password) => {
	await delay(800);

	const user = mockUsers.find(u => u.uname === uname && u.password === password);

	if (user) {
		const {
			password: pwd,
			...userInfo
		} = user;
		return mockResponse({
			token: 'mock_token_' + Date.now(),
			userInfo
		}, '登录成功');
	}

	return mockError('用户名或密码错误', 401);
};

/**
 * 模拟注册
 */
export const mockRegister = async (data) => {
	await delay(800);

	// 检查用户名是否已存在
	const exists = mockUsers.find(u => u.uname === data.uname);
	if (exists) {
		return mockError('用户名已存在', 400);
	}

	// 模拟创建新用户
	const newUser = {
		userId: mockUsers.length + 1,
		...data,
		avatar: 'https://picsum.photos/200/200?random=' + (mockUsers.length + 1),
		role: 0,
		status: 0,
		createTime: Date.now()
	};

	mockUsers.push(newUser);

	return mockResponse({
		userId: newUser.userId
	}, '注册成功');
};

/**
 * 模拟获取用户信息
 */
export const mockGetUserInfo = async (userId) => {
	await delay(300);

	const user = mockUsers.find(u => u.userId === userId);

	if (user) {
		const {
			password,
			...userInfo
		} = user;
		return mockResponse(userInfo);
	}

	return mockError('用户不存在', 404);
};

/**
 * 模拟更新用户信息
 */
export const mockUpdateUser = async (data) => {
	await delay(500);

	const userIndex = mockUsers.findIndex(u => u.userId === data.userId);

	if (userIndex !== -1) {
		mockUsers[userIndex] = {
			...mockUsers[userIndex],
			...data
		};
		return mockResponse(null, '更新成功');
	}

	return mockError('用户不存在', 404);
};

// ====================================================================
// 帖子相关 Mock API
// ====================================================================

/**
 * 模拟获取帖子列表
 */
export const mockGetPosts = async (params = {}) => {
	await delay(500);

	let posts = [...mockPosts];

	// 筛选板块
	if (params.plateId) {
		posts = posts.filter(p => p.plateId == params.plateId);
	}

	// 筛选子分类
	if (params.subCategory) {
		posts = posts.filter(p => p.subCategory === params.subCategory);
	}

	// 搜索标题
	if (params.title) {
		posts = posts.filter(p => p.title.includes(params.title));
	}

	// 筛选用户
	if (params.userId) {
		posts = posts.filter(p => p.userId == params.userId);
	}

	// 排序（置顶优先，然后按时间）
	posts.sort((a, b) => {
		if (a.isTop !== b.isTop) {
			return b.isTop - a.isTop;
		}
		return b.createTime - a.createTime;
	});

	// 分页
	const pageNum = params.pageNum || 1;
	const pageSize = params.pageSize || 10;
	const start = (pageNum - 1) * pageSize;
	const end = start + pageSize;

	return mockResponse({
		list: posts.slice(start, end),
		total: posts.length,
		pageNum,
		pageSize
	});
};

/**
 * 模拟获取帖子详情
 */
export const mockGetPost = async (postId) => {
	await delay(300);

	const post = mockPosts.find(p => p.postId == postId);

	if (post) {
		// 模拟增加浏览量
		post.viewCount++;
		return mockResponse(post);
	}

	return mockError('帖子不存在', 404);
};

/**
 * 模拟发布帖子
 */
export const mockPublishPost = async (data) => {
	await delay(800);

	const newPost = {
		postId: mockPosts.length + 1,
		...data,
		viewCount: 0,
		likeCount: 0,
		collectCount: 0,
		commentCount: 0,
		isTop: 0,
		isEssence: 0,
		status: 0,
		createTime: Date.now(),
		updateTime: Date.now()
	};

	// 获取用户信息
	const user = mockUsers.find(u => u.userId === data.userId);
	if (user) {
		newPost.nickname = user.nickname;
		newPost.avatar = user.avatar;
	}

	mockPosts.unshift(newPost);

	return mockResponse({
		postId: newPost.postId
	}, '发布成功');
};

/**
 * 模拟删除帖子
 */
export const mockDeletePost = async (postId) => {
	await delay(500);

	const index = mockPosts.findIndex(p => p.postId == postId);

	if (index !== -1) {
		mockPosts.splice(index, 1);
		return mockResponse(null, '删除成功');
	}

	return mockError('帖子不存在', 404);
};

// ====================================================================
// 评论相关 Mock API
// ====================================================================

/**
 * 模拟获取评论列表
 */
export const mockGetComments = async (postId) => {
	await delay(300);

	const comments = mockComments.filter(c => c.postId == postId);

	return mockResponse(comments);
};

/**
 * 模拟发布评论
 */
export const mockPublishComment = async (data) => {
	await delay(500);

	const newComment = {
		commentId: mockComments.length + 1,
		...data,
		status: 0,
		createTime: Date.now()
	};

	// 获取用户信息
	const user = mockUsers.find(u => u.userId === data.userId);
	if (user) {
		newComment.sender = user.nickname;
		newComment.senderAvatar = user.avatar;
	}

	mockComments.push(newComment);

	// 更新帖子评论数
	const post = mockPosts.find(p => p.postId == data.postId);
	if (post) {
		post.commentCount++;
	}

	return mockResponse({
		commentId: newComment.commentId
	}, '评论成功');
};

// ====================================================================
// 板块相关 Mock API
// ====================================================================

/**
 * 模拟获取板块列表（一级板块）
 */
export const mockGetPlates = async () => {
	await delay(200);
	return mockResponse(mockPlates);
};

/**
 * 模拟获取子分类列表
 * @param {number} plateId - 一级板块ID
 */
export const mockGetSubCategories = async (plateId) => {
	await delay(200);
	const subCategories = mockSubCategories[plateId] || [];
	return mockResponse(subCategories);
};

// ====================================================================
// 活动相关 Mock API
// ====================================================================

/**
 * 模拟获取活动列表
 */
export const mockGetActivities = async (params = {}) => {
	await delay(500);

	let activities = [...mockActivities];

	// 筛选状态
	if (params.status !== undefined) {
		activities = activities.filter(a => a.status == params.status);
	}

	// 分页
	const pageNum = params.pageNum || 1;
	const pageSize = params.pageSize || 10;
	const start = (pageNum - 1) * pageSize;
	const end = start + pageSize;

	return mockResponse(activities.slice(start, end));
};

/**
 * 模拟获取活动详情
 */
export const mockGetActivity = async (activityId) => {
	await delay(300);

	const activity = mockActivities.find(a => a.activityId == activityId);

	if (activity) {
		return mockResponse(activity);
	}

	return mockError('活动不存在', 404);
};

// ====================================================================
// 公告相关 Mock API
// ====================================================================

/**
 * 模拟获取公告列表
 */
export const mockGetNotices = async (params = {}) => {
	await delay(300);

	let notices = [...mockNotices];

	// 筛选类型
	if (params.type) {
		notices = notices.filter(n => n.type === params.type);
	}

	// 分页
	const pageNum = params.pageNum || 1;
	const pageSize = params.pageSize || 10;
	const start = (pageNum - 1) * pageSize;
	const end = start + pageSize;

	return mockResponse(notices.slice(start, end));
};

// ====================================================================
// 点赞、收藏、关注相关（简化版）
// ====================================================================

/**
 * 模拟点赞
 */
export const mockLikePost = async (postId) => {
	await delay(300);

	const post = mockPosts.find(p => p.postId == postId);
	if (post) {
		post.likeCount++;
		return mockResponse(null, '点赞成功');
	}

	return mockError('帖子不存在', 404);
};

/**
 * 模拟取消点赞
 */
export const mockUnlikePost = async (postId) => {
	await delay(300);

	const post = mockPosts.find(p => p.postId == postId);
	if (post && post.likeCount > 0) {
		post.likeCount--;
		return mockResponse(null, '取消点赞成功');
	}

	return mockError('操作失败', 400);
};

/**
 * 模拟收藏
 */
export const mockCollectPost = async (postId) => {
	await delay(300);

	const post = mockPosts.find(p => p.postId == postId);
	if (post) {
		post.collectCount++;
		return mockResponse(null, '收藏成功');
	}

	return mockError('帖子不存在', 404);
};

/**
 * 模拟取消收藏
 */
export const mockUncollectPost = async (postId) => {
	await delay(300);

	const post = mockPosts.find(p => p.postId == postId);
	if (post && post.collectCount > 0) {
		post.collectCount--;
		return mockResponse(null, '取消收藏成功');
	}

	return mockError('操作失败', 400);
};

/**
 * 添加帖子（用于商品发布、求助发布等）
 */
export const mockAddPost = async (postData) => {
	await mockDelay();

	// 生成新帖子ID
	const newPostId = mockPosts.length > 0 ? Math.max(...mockPosts.map(p => p.postId)) + 1 : 1;

	// 创建新帖子对象
	const newPost = {
		postId: newPostId,
		userId: 1, // 模拟当前登录用户
		plateId: postData.plateId,
		subCategory: postData.subCategory || null,
		title: postData.title,
		content: postData.content,
		images: postData.images || [],
		createTime: new Date().toISOString(),
		viewCount: 0,
		likeCount: 0,
		commentCount: 0,
		collectCount: 0,
		status: 0,
		
		// 交易相关字段
		tradePrice: postData.tradePrice || null,
		tradeCondition: postData.tradeCondition || null,
		tradeMethods: postData.tradeMethods || null,
		tradeStatus: postData.tradeStatus || 0,
		
		// 求助相关字段
		helpUrgency: postData.helpUrgency || null,
		helpReward: postData.helpReward || null,
		helpStatus: postData.helpStatus || 0,
		
		// 联系方式
		contactInfo: postData.contactInfo || null,
		
		// 附加信息
		attachments: postData.attachments || null,
		note: postData.note || null
	};

	// 添加到帖子列表
	mockPosts.unshift(newPost);

	return mockResponse(newPost, '发布成功');
};

// ====================================================================
// 聊天室相关 Mock API
// ====================================================================

/**
 * 模拟获取聊天室列表（只返回当前用户已加入的）
 */
export const mockGetChatrooms = async (params = {}) => {
	await delay(500);

	// 获取当前用户已加入的聊天室ID列表
	const currentUserId = 2; // 模拟当前用户ID
	const joinedRoomIds = mockUserChatroomRelations
		.filter(rel => rel.userId === currentUserId && rel.status === 'joined')
		.map(rel => rel.roomId);

	// 只返回已加入的聊天室
	let chatrooms = mockChatrooms.filter(room => joinedRoomIds.includes(room.roomId));

	// 搜索关键词
	if (params.keyword) {
		chatrooms = chatrooms.filter(room => 
			room.roomName.includes(params.keyword) || 
			room.roomDesc.includes(params.keyword)
		);
	}

	// 排序（按最后消息时间）
	chatrooms.sort((a, b) => b.lastMessageTime - a.lastMessageTime);

	// 分页
	const pageNum = params.pageNum || 1;
	const pageSize = params.pageSize || 20;
	const start = (pageNum - 1) * pageSize;
	const end = start + pageSize;

	return mockResponse({
		list: chatrooms.slice(start, end),
		total: chatrooms.length,
		pageNum,
		pageSize
	});
};

/**
 * 模拟获取所有聊天室列表（包含加入状态）
 */
export const mockGetAllChatrooms = async (params = {}) => {
	await delay(500);

	const currentUserId = 2; // 模拟当前用户ID
	
	let chatrooms = mockChatrooms.map(room => {
		// 查找用户与聊天室的关系
		const relation = mockUserChatroomRelations.find(
			rel => rel.userId === currentUserId && rel.roomId === room.roomId
		);
		
		return {
			...room,
			joinStatus: relation ? relation.status : 'not_joined'
		};
	});

	// 搜索关键词
	if (params.keyword) {
		chatrooms = chatrooms.filter(room => 
			room.roomName.includes(params.keyword) || 
			room.roomDesc.includes(params.keyword)
		);
	}

	// 排序（已加入的在前面，然后按成员数排序）
	chatrooms.sort((a, b) => {
		if (a.joinStatus === 'joined' && b.joinStatus !== 'joined') return -1;
		if (a.joinStatus !== 'joined' && b.joinStatus === 'joined') return 1;
		return b.memberCount - a.memberCount;
	});

	// 分页
	const pageNum = params.pageNum || 1;
	const pageSize = params.pageSize || 20;
	const start = (pageNum - 1) * pageSize;
	const end = start + pageSize;

	return mockResponse({
		list: chatrooms.slice(start, end),
		total: chatrooms.length,
		pageNum,
		pageSize
	});
};

/**
 * 模拟获取聊天室详情
 */
export const mockGetChatroomDetail = async (roomId) => {
	await delay(300);

	const chatroom = mockChatrooms.find(r => r.roomId == roomId);

	if (chatroom) {
		return mockResponse(chatroom);
	}

	return mockError('聊天室不存在', 404);
};

/**
 * 模拟创建聊天室
 */
export const mockCreateChatroom = async (data) => {
	await delay(800);

	// 获取当前用户信息（这里模拟使用ID为2的用户）
	const currentUser = mockUsers.find(u => u.userId === 2);

	const newChatroom = {
		roomId: mockChatrooms.length + 1,
		roomName: data.roomName,
		roomDesc: data.roomDesc || '',
		avatar: 'https://picsum.photos/200/200?random=' + (100 + mockChatrooms.length + 1),
		creatorId: currentUser.userId,
		creatorName: currentUser.nickname,
		onlineCount: 1,
		memberCount: 1,
		lastMessage: '聊天室已创建',
		lastMessageTime: Date.now(),
		unreadCount: 0,
		status: 0,
		createTime: Date.now()
	};

	mockChatrooms.unshift(newChatroom);

	// 初始化该聊天室的消息列表
	mockChatroomMessages[newChatroom.roomId] = [];

	return mockResponse({
		roomId: newChatroom.roomId
	}, '创建成功');
};

/**
 * 模拟删除聊天室
 */
export const mockDeleteChatroom = async (roomId) => {
	await delay(500);

	const index = mockChatrooms.findIndex(r => r.roomId == roomId);

	if (index !== -1) {
		mockChatrooms.splice(index, 1);
		// 删除该聊天室的消息
		delete mockChatroomMessages[roomId];
		return mockResponse(null, '删除成功');
	}

	return mockError('聊天室不存在', 404);
};

/**
 * 模拟获取聊天室消息列表
 */
export const mockGetChatroomMessages = async (roomId) => {
	await delay(300);

	const messages = mockChatroomMessages[roomId] || [];

	return mockResponse(messages);
};

/**
 * 模拟发送消息
 */
export const mockSendMessage = async (data) => {
	await delay(300);

	// 获取当前用户信息（这里模拟使用ID为2的用户）
	const currentUser = mockUsers.find(u => u.userId === 2);

	// 生成消息ID
	let maxMessageId = 0;
	Object.values(mockChatroomMessages).forEach(messages => {
		messages.forEach(msg => {
			if (msg.messageId > maxMessageId) {
				maxMessageId = msg.messageId;
			}
		});
	});

	const newMessage = {
		messageId: maxMessageId + 1,
		roomId: data.roomId,
		userId: currentUser.userId,
		nickname: currentUser.nickname,
		avatar: currentUser.avatar,
		type: data.type,
		content: data.content,
		isSelf: true,
		createTime: Date.now()
	};

	// 初始化消息列表（如果不存在）
	if (!mockChatroomMessages[data.roomId]) {
		mockChatroomMessages[data.roomId] = [];
	}

	// 添加消息
	mockChatroomMessages[data.roomId].push(newMessage);

	// 更新聊天室的最后消息
	const chatroom = mockChatrooms.find(r => r.roomId == data.roomId);
	if (chatroom) {
		chatroom.lastMessage = data.type === 'text' ? data.content : '[图片]';
		chatroom.lastMessageTime = Date.now();
	}

	return mockResponse(newMessage, '发送成功');
};

/**
 * 模拟加入聊天室
 */
export const mockJoinChatroom = async (roomId) => {
	await delay(500);

	const currentUserId = 2; // 模拟当前用户ID

	// 检查是否已加入
	const existingRelation = mockUserChatroomRelations.find(
		rel => rel.userId === currentUserId && rel.roomId === roomId
	);

	if (existingRelation) {
		if (existingRelation.status === 'joined') {
			return mockError('已经加入该聊天室', 400);
		} else if (existingRelation.status === 'pending') {
			return mockError('申请审核中', 400);
		}
	}

	// 添加关系
	mockUserChatroomRelations.push({
		userId: currentUserId,
		roomId: roomId,
		status: 'joined', // 直接加入，不需要审核
		joinTime: Date.now()
	});

	// 更新聊天室成员数
	const chatroom = mockChatrooms.find(r => r.roomId === roomId);
	if (chatroom) {
		chatroom.memberCount++;
	}

	return mockResponse(null, '加入成功');
};

// ====================================================================
// 消息通知相关 Mock API
// ====================================================================

/**
 * 模拟获取消息列表
 */
export const mockGetMessages = async (params = {}) => {
	await delay(500);

	let messages = [...mockMessages];

	// 筛选消息类型
	if (params.type) {
		messages = messages.filter(m => m.type === params.type);
	}

	// 筛选已读/未读
	if (params.isRead !== undefined && params.isRead !== null && params.isRead !== '') {
		messages = messages.filter(m => m.isRead == params.isRead);
	}

	// 按时间倒序排列
	messages.sort((a, b) => b.createTime - a.createTime);

	// 分页
	const pageNum = params.pageNum || 1;
	const pageSize = params.pageSize || 20;
	const start = (pageNum - 1) * pageSize;
	const end = start + pageSize;

	return mockResponse({
		list: messages.slice(start, end),
		total: messages.length,
		pageNum,
		pageSize
	});
};

/**
 * 模拟获取消息详情
 */
export const mockGetMessageDetail = async (messageId) => {
	await delay(300);

	const message = mockMessages.find(m => m.messageId == messageId);

	if (message) {
		// 自动标记为已读
		message.isRead = 1;
		return mockResponse(message);
	}

	return mockError('消息不存在', 404);
};

/**
 * 模拟标记消息为已读
 */
export const mockMarkMessageAsRead = async (messageId) => {
	await delay(300);

	const message = mockMessages.find(m => m.messageId == messageId);

	if (message) {
		message.isRead = 1;
		return mockResponse(null, '标记成功');
	}

	return mockError('消息不存在', 404);
};

/**
 * 模拟标记所有消息为已读
 */
export const mockMarkAllAsRead = async (type) => {
	await delay(500);

	let count = 0;
	mockMessages.forEach(message => {
		if (!type || message.type === type) {
			if (message.isRead === 0) {
				message.isRead = 1;
				count++;
			}
		}
	});

	return mockResponse({ count }, `已标记${count}条消息为已读`);
};

/**
 * 模拟获取未读消息数量
 */
export const mockGetUnreadCount = async () => {
	await delay(200);

	const unreadCounts = {
		total: 0,
		reply: 0,
		system: 0,
		official: 0,
		activity: 0,
		other: 0
	};

	mockMessages.forEach(message => {
		if (message.isRead === 0) {
			unreadCounts.total++;
			unreadCounts[message.type]++;
		}
	});

	return mockResponse(unreadCounts);
};

// ====================================================================
// 导出所有 Mock API
// ====================================================================
export default {
	// 用户相关
	mockLogin,
	mockRegister,
	mockGetUserInfo,
	mockUpdateUser,

	// 帖子相关
	mockGetPosts,
	mockGetPost,
	mockPublishPost,
	mockAddPost,
	mockDeletePost,

	// 评论相关
	mockGetComments,
	mockPublishComment,

	// 板块相关
	mockGetPlates,
	mockGetSubCategories,

	// 活动相关
	mockGetActivities,
	mockGetActivity,

	// 公告相关
	mockGetNotices,

	// 点赞收藏
	mockLikePost,
	mockUnlikePost,
	mockCollectPost,
	mockUncollectPost,

	// 聊天室相关
	mockGetChatrooms,
	mockGetAllChatrooms,
	mockGetChatroomDetail,
	mockCreateChatroom,
	mockDeleteChatroom,
	mockGetChatroomMessages,
	mockSendMessage,
	mockJoinChatroom,

	// 消息通知相关
	mockGetMessages,
	mockGetMessageDetail,
	mockMarkMessageAsRead,
	mockMarkAllAsRead,
	mockGetUnreadCount
};

